|
|
|
|
|
|
|
The Stocks1 program described earlier in this chapter uses a simple kind of script. When it starts, the program fills its Data array with random stock values. The value of stock number S during frame F is given by Data(F, S). The Data array indicates exactly what values the animation should display during each frame, so it forms a script for the program's animation. |
|
|
|
|
|
|
|
|
Example program Robot, shown in Figure 9.1, is a robot script editor. The program's drawing area shows a stick figure robot. Using the commands in the Frames menu, you can add or delete frames from the script. Use the scrollbar to select a frame to edit. Then use the mouse to click and drag the robot's control points. The program saves the robot's position and the angles at which its arms and legs are bent in an array entry corresponding to the frame you have selected. This array forms the script for the animation. |
|
|
|
|
|
|
|
|
When you are satisfied with the script, select the type of animation you want to see, and click the Play button. If you select the Once option, the program runs the animation once and then stops. If you select Looping, the program plays the script repeatedly until you click the Stop button. If you click the Reversing button, the program runs the script forward and backward until you stop it. |
|
|
|
|
|
|
|
|
To make working with scripts easier, the program's File menu contains commands for loading and saving scripts. The file Jacks.rob in the Ch9 directory on the CD-ROM contains a script that makes the robot do jumping jacks. Try running this script in a reversing animation at 20 frames per second. The script file Run.rob makes the robot run. Play this file in a looping animation. |
|
|
|
|
|
|
|
|
This simple scripted animation is quite fast. With a 133MHz Pentium, it can display more than 400 frames per second. The program achieves its remarkable performance by using a blank background. Because the background is blank, the program can set the drawing area's AutoRedraw property to False and quickly clear it using SetBitmapBits. If the |
|
|
|
|
|
|
|
|
Figure 9.1
Program Robot editing a robot script. |
|
|
|
|
|